/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.gov.cemaden.library.model.staff;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 * @author alan
 */
@Entity
@Table(name = "stf_execucao", schema = "staff")
@NamedQueries({
    @NamedQuery(name = "Execucao.findLastByAplicacao", 
            query = "SELECT e FROM Execucao e WHERE fim = (SELECT MAX(fim) FROM Execucao x WHERE x.aplicacao = :aplicacao)")
})
public class Execucao implements Serializable {
    
    @Id
    @Column(name = "id_execucao", unique = true, nullable = false)
    private Long id;
    
    @Column(name = "descricao")
    private String descricao;
    
    @Column(name = "inicio")
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date inicio;
    
    @Column(name = "fim")
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date fim;
    
    @Column(name = "status")
    private Integer status;
    
    @ManyToOne
    @JoinColumn(name = "id_aplicacao")
    private Aplicacao aplicacao;
    
    public Execucao(){
        
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Date getInicio() {
        return inicio;
    }

    public void setInicio(Date inicio) {
        this.inicio = inicio;
    }

    public Date getFim() {
        return fim;
    }

    public void setFim(Date fim) {
        this.fim = fim;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Aplicacao getAplicacao() {
        return aplicacao;
    }

    public void setAplicacao(Aplicacao aplicacao) {
        this.aplicacao = aplicacao;
    }
    
    
    
}
